How to Program Raspberry Pi Pico With the Arduino IDE

Program Raspberry Pi Pico with Arduino IDE
(Image credit: Tom's Hardware)

Wiring code for your Raspberry Pi Pico can fall into two categories. The easy way for new users is to use a version of Python such as MicroPython or CircuitPython. A more advanced way is to write code in C / C++ which is for more confident users.

There is now a third way that we can write code for our Raspberry Pi Pico, and that is via the Arduino IDE, which uses “Arduino Language,” a derivative of C++. Because Arduino has been around for so many years, there’s a ton of pre-existing “sketches” (the Arduino term for programs) and tutorials for it. If you’ve worked with Arduino boards before, you may be very familiar with this powerful IDE and language.

Raspberry Pi Pico

Raspberry Pi Pico

(Image credit: PiShopUs)

View at PiShop.us

We’ve gone through many different setup processes and found two community created projects that streamline the installation process to just a handful of steps. The first is pico-setup-windows which is a Windows port of the official Pico setup script. The second is Arduino-Pico which adds support for the Raspberry Pi Pico to the Arduino IDE. In this tutorial we show you how to set up your Windows or Ubuntu machine to write Arduino code on your Raspberry Pi Pico 

How to Program Raspberry Pi Pico in Arduino IDE for Windows 

1. Download the pico-setup-windows installer. This is a fairly large download.

2. Launch the installer. 

(Image credit: Tom's Hardware)

3.  Ensure that all of the components are selected. This will install approximately 360MB of files and applications to your machine. Including the files necessary for building C/C++ files, Visual Studio Code, and Git version control. 

(Image credit: Tom's Hardware)

4. Click Install to install all of the applications. This can take some time, and at times it may appear stuck, but be patient. 

Program Raspberry Pi Pico With the Arduino IDE

(Image credit: Tom's Hardware)

5. Download the Arduino IDE and install it to your machine. We chose v 1.8.13, but the beta of v 2.0 also works.

6. Open the Arduino application and navigate to File >> Preferences.

7. In the additional boards manager, add this line and click OK

https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json

Program Raspberry Pi Pico With the Arduino IDE

(Image credit: Tom's Hardware)

8. Go to Tools >>  Board >> Boards Manager

(Image credit: Tom's Hardware)

9. Type “pico” in the search box and then install the Raspberry Pi Pico / RP2040 board. This will trigger another large download, approximately 300MB in size. 

(Image credit: Tom's Hardware)

10. Go to Tools >> Board >> Raspberry Pi RP2040 Boards and select Raspberry Pi Pico.

(Image credit: Tom's Hardware)

11. Connect your Raspberry Pi Pico and using Device Manager locate the COM port that it is connected to. 

(Image credit: Tom's Hardware)

12. Under Tools >> Port, set the COM port for the Raspberry Pi Pico. 

(Image credit: Tom's Hardware)

13. Open Files >> Examples >> Basics >> Blink to test that we can write code to the Arduino. 

(Image credit: Tom's Hardware)

14. Click on Upload to write the code to the Raspberry Pi Pico. The default Blink sketch will flash the green LED next to the micro USB port on the Raspberry Pi Pico. 

(Image credit: Tom's Hardware)

(Image credit: Tom's Hardware)

The output window will tell us when the upload is complete. Look at your Raspberry Pi Pico and you will see the green LED flashing once per second. 

How to Program Raspberry Pi Pico in Arduino IDE for Linux 

We used Ubuntu for this tutorial, but the same instructions should work for other Debian based distributions such as Raspberry Pi OS.

1. Open a terminal and use wget to download the official Pico setup script.

$ wget https://raw.githubusercontent.com/raspberrypi/pico-setup/master/pico_setup.sh

2. In the same terminal modify the downloaded file so that it is executable.

$ chmod +x pico_setup.sh

3. Run pico_setup.sh to start the installation process. Enter your sudo password if prompted.

$ ./pico_setup.sh

4. Download the Arduino IDE and install it to your machine. We chose v 1.8.13, but the beta of v 2.0 also works.

5. Open a terminal and add your user to the group “dialout.” This group can communicate with devices such as the Arduino. Using “$USER” will automatically use your username.

$ sudo usermod -a -G dialout “$USER”

6. Log out or reboot your computer for the changes to take effect.

7. Open the Arduino application and go to File >> Preferences.

8. In the additional boards manager add this line and click OK.

https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json

(Image credit: Tom's Hardware)

9. Go to Tools >>  Board >> Boards Manager.

10. Type “pico” in the search box and then install the Raspberry Pi Pico / RP2040 board. This will trigger another large download, approximately 300MB in size. 

(Image credit: Tom's Hardware)

11. Go to Tools >> Board >> Raspberry Pi RP2040 Boards and select Raspberry Pi Pico.

(Image credit: Tom's Hardware)

12. Connect your Raspberry Pi Pico

13. Run a command to locate the USB device which identifies as a Raspberry Pi Pico. In our case it was ttyACM0.

$ dmesg

(Image credit: Tom's Hardware)

14. Open Files >> Examples >> Basics >> Blink to test that we can write code to the Arduino.

(Image credit: Tom's Hardware)

15. Click on Upload to write the code to the Raspberry Pi Pico. The default Blink sketch will flash the green LED next to the micro USB port on the Raspberry Pi Pico.

(Image credit: Tom's Hardware)

The output window will tell us when the upload is complete. Look at your Raspberry Pi Pico and you will see the green LED flashing once per second.

(Image credit: Tom's Hardware)

Raspberry Pi Pico Tutorials:

Les Pounder

Les Pounder is an associate editor at Tom's Hardware. He is a creative technologist and for seven years has created projects to educate and inspire minds both young and old. He has worked with the Raspberry Pi Foundation to write and deliver their teacher training program "Picademy".

  • softeky
    Just a heads-up. Following installation instructions for Linux I ran into a couple of snags.
    (1) I'm compiling on Raspberry (Linux rpi 4.19.66-v7+ #1253 SMP Thu Aug 15 11:49:46 BST 2019 armv7l GNU/Linux). Not the most update but... "./pico_setup.sh" won't use cmake that comes with the OS. "apt-get" won't go above v3.7 which fails the script.

    I backtracked...
    Read More Reply
  • softeky
    softeky said:
    Just a heads-up. Following installation instructions for Linux I ran into a couple of snags.
    ...

    Replying to my own post (sorry). Just continuing the saga, trying to get Debian on Raspberry Pi to load the Linux package that gets the Arduino IDE to support Raspberry Pico development.

    ...continuing...

    The source issue is the compiler...
    Read More Reply
  • softeky
    softeky said:
    Replying to my own post again (sorry). Still continuing the saga, trying to get Debian on Raspberry Pi v3 to load the Linux package that gets the Arduino IDE to support Raspberry Pico development.

    ...continuing...

    Processing triggers for gnome-menus (3.13.3-9) ...
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Unable...
    Read More Reply
  • seamusdemora
    This is pretty awful! It's not been maintained, and is now full of outdated information. In my case, even blink won't work - this is the error message:
    Sketch uses 89816 bytes (4%) of program storage space. Maximum is 2097152 bytes.
    Global variables use 42824 bytes (15%) of dynamic memory, leaving 227512 bytes for local variables. Maximum is 270336...
    Read More Reply